package com.sdhs.myproject.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.sdhs.common.annotation.Log;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.core.page.TableDataInfo;
import com.sdhs.common.enums.BusinessType;
import com.sdhs.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sdhs.myproject.domain.GcMyprojectProfitMarginMeasurement;
import com.sdhs.myproject.service.IGcMyprojectProfitMarginMeasurementService;


/**
 * 我的项目--利润率测算Controller
 *
 * @author andong
 * @date 2025-03-11
 */
@RestController
@RequestMapping("/myproject/measurement")
public class GcMyprojectProfitMarginMeasurementController extends BaseController
{
    @Autowired
    private IGcMyprojectProfitMarginMeasurementService gcMyprojectProfitMarginMeasurementService;

    /**
     * 查询我的项目--利润率测算列表
     */
    @PreAuthorize("@ss.hasPermi('myproject:measurement:list')")
    @GetMapping("/list")
    public TableDataInfo list(GcMyprojectProfitMarginMeasurement gcMyprojectProfitMarginMeasurement)
    {
        startPage();
        List<GcMyprojectProfitMarginMeasurement> list = gcMyprojectProfitMarginMeasurementService.selectGcMyprojectProfitMarginMeasurementList(gcMyprojectProfitMarginMeasurement);
        return getDataTable(list);
    }

    /**
     * 导出我的项目--利润率测算列表
     */
    @PreAuthorize("@ss.hasPermi('myproject:measurement:export')")
    @Log(title = "我的项目--利润率测算", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GcMyprojectProfitMarginMeasurement gcMyprojectProfitMarginMeasurement)
    {
        List<GcMyprojectProfitMarginMeasurement> list = gcMyprojectProfitMarginMeasurementService.selectGcMyprojectProfitMarginMeasurementList(gcMyprojectProfitMarginMeasurement);
        ExcelUtil<GcMyprojectProfitMarginMeasurement> util = new ExcelUtil<GcMyprojectProfitMarginMeasurement>(GcMyprojectProfitMarginMeasurement.class);
        util.exportExcel(response, list, "我的项目--利润率测算数据");
    }

    /**
     * 获取我的项目--利润率测算详细信息
     */
    @PreAuthorize("@ss.hasPermi('myproject:measurement:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gcMyprojectProfitMarginMeasurementService.selectGcMyprojectProfitMarginMeasurementById(id));
    }

    /**
     * 新增我的项目--利润率测算
     */
    @PreAuthorize("@ss.hasPermi('myproject:measurement:add')")
    @Log(title = "我的项目--利润率测算", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GcMyprojectProfitMarginMeasurement gcMyprojectProfitMarginMeasurement)
    {
        return toAjax(gcMyprojectProfitMarginMeasurementService.insertGcMyprojectProfitMarginMeasurement(gcMyprojectProfitMarginMeasurement));
    }

    /**
     * 修改我的项目--利润率测算
     */
    @PreAuthorize("@ss.hasPermi('myproject:measurement:edit')")
    @Log(title = "我的项目--利润率测算", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GcMyprojectProfitMarginMeasurement gcMyprojectProfitMarginMeasurement)
    {
        return toAjax(gcMyprojectProfitMarginMeasurementService.updateGcMyprojectProfitMarginMeasurement(gcMyprojectProfitMarginMeasurement));
    }

    /**
     * 删除我的项目--利润率测算
     */
    @PreAuthorize("@ss.hasPermi('myproject:measurement:remove')")
    @Log(title = "我的项目--利润率测算", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gcMyprojectProfitMarginMeasurementService.deleteGcMyprojectProfitMarginMeasurementByIds(ids));
    }
}
